//
//  YIMUtils.swift
//  YIM
//
//  Created by YMac on 09/02/2022.
//  Copyright © 2022 zchd. All rights reserved.
//

import Foundation

internal class QhRdOrIHpflpNVmj {
    func aKdyLQPwRZgdzpAx(IMuPBNSVQxljIWnu: String) {
        if NbDnvbpESqnqDInl.SoORWivnNfUskmhc.ThsZAORRnwdIdKMH { debugPrint("[YIMLog]: \(IMuPBNSVQxljIWnu)") }
    }
    
    func xtovshfHwqTsyirV(_ EeqbYNIBaZfkqYaF: Any) -> String {
        switch EeqbYNIBaZfkqYaF {
        case is Encodable:
            let EeqbYNIBaZfkqYaF = EeqbYNIBaZfkqYaF as! Encodable
            return String(data: try! JSONEncoder().encode(EeqbYNIBaZfkqYaF), encoding: .utf8)!
        default:
            return String(data: try! JSONSerialization.data(withJSONObject: EeqbYNIBaZfkqYaF), encoding: .utf8)!
        }
    }
    
    func IYMCIgmwfHIBQjIX<T: Decodable>(_ JHSuCzSyvFYKbYoP: Any?, _ MiacOEytWLrYAGpo: T.Type) -> T? {
        if JHSuCzSyvFYKbYoP == nil { return nil }
        do {
            switch JHSuCzSyvFYKbYoP {
            case is String:
                return try JSONDecoder().decode(MiacOEytWLrYAGpo, from: (JHSuCzSyvFYKbYoP as! String).data(using: .utf8)!)
            default:
                return try JSONDecoder().decode(MiacOEytWLrYAGpo, from: xtovshfHwqTsyirV(JHSuCzSyvFYKbYoP!).data(using: .utf8)!)
            }
        } catch {
            print(error)
            return nil
        }
    }
    
    func GkNTaCvzlvcowaSg(_ JHSuCzSyvFYKbYoP: String?) -> NSMutableDictionary? {
        if JHSuCzSyvFYKbYoP == nil { return nil }
        if let yumlNTvUJnwUTrPR = JHSuCzSyvFYKbYoP!.data(using: .utf8) {
            do {
                return NSMutableDictionary(dictionary: try JSONSerialization.jsonObject(with: yumlNTvUJnwUTrPR, options: []) as! NSDictionary)
            } catch {
                return nil
            }
        }
        return nil
    }
    
    func oGyUzfiicTuvfkwc(VuFCApXqAiuIKaUF: String) -> Int {
        do {
            let attr = try FileManager.default.attributesOfItem(atPath: VuFCApXqAiuIKaUF)
            return Int(attr[.size] as! UInt64)
        } catch {
            return 0
        }
    }
    
    func CzkztFjgxzeSorYu(_ tSvnyFpPNIuhsueO: TimeInterval = 0, _ lnPbkmdwNECDwBnh: @escaping () throws -> Void) {
        Timer.scheduledTimer(withTimeInterval: tSvnyFpPNIuhsueO, repeats: false) { _ in
            DispatchQueue.main.async {
                do {
                    try lnPbkmdwNECDwBnh()
                } catch {
                    print(error)
                }
            }
        }
    }
    
    func VBxorykRlBCVhSNZ(IMuPBNSVQxljIWnu: String) -> String {
        func aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: String) -> String {
            return IMuPBNSVQxljIWnu.data(using: .utf8)!.base64EncodedString()
        }
        
        let riMnWhgFsElZCQnQ = "123a56788765a321"
        return aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: "\(riMnWhgFsElZCQnQ)\(aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: "\(riMnWhgFsElZCQnQ)\(IMuPBNSVQxljIWnu)\(riMnWhgFsElZCQnQ)"))\(riMnWhgFsElZCQnQ)")
    }
    
    func epGrfPUosodDOBQU(IMuPBNSVQxljIWnu: String) -> String {
        func aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: String) -> String {
                return String(data: Data(base64Encoded: IMuPBNSVQxljIWnu)!, encoding: .utf8)!
        }
        
        func iMAUCLxhMhaFIeAg(KjiUjhHsaFpvZWql: String, OKahPJCbMTVFwzpq: String) -> String {
            var kKsxeMWRvxOisRhl = KjiUjhHsaFpvZWql
            if kKsxeMWRvxOisRhl.hasPrefix(OKahPJCbMTVFwzpq) {
                kKsxeMWRvxOisRhl.removeFirst(OKahPJCbMTVFwzpq.count)
            }
            if kKsxeMWRvxOisRhl.hasSuffix(OKahPJCbMTVFwzpq) {
                kKsxeMWRvxOisRhl.removeLast(OKahPJCbMTVFwzpq.count)
            }
            return kKsxeMWRvxOisRhl
        }
        
        let riMnWhgFsElZCQnQ = "123a56788765a321"
        return iMAUCLxhMhaFIeAg(KjiUjhHsaFpvZWql: aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: iMAUCLxhMhaFIeAg(KjiUjhHsaFpvZWql: aZHKXnlMKAdcWOOS(IMuPBNSVQxljIWnu: IMuPBNSVQxljIWnu), OKahPJCbMTVFwzpq: riMnWhgFsElZCQnQ)), OKahPJCbMTVFwzpq: riMnWhgFsElZCQnQ)
    }
}
